<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'weiye1.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
<div id="dyn">
		<div>
			<center>
				<table  width="1000;" height="300" align="center">
					<tr>
						<th>景点编号</th>
						<th>景点名称</th>
						<th>票价/元</th>
						<th>景点地址</th>
						<th>景点预览</th>
						<th>景点介绍</th>
						<th>操作</th>
					</tr>

					<c:forEach items="${list}" var="u">

						<tr>
							<td><input type="text" value="${u.sceneryId}" name="id"
								id="id${u.sceneryId}" style="border: none;" /></td>
							<td><input type="text" value="${u.sceneryName}" name="name"
								id="name${u.sceneryId}" style="border: none;" /></td>
							<td><input type="text" value="${u.ticketPrice }"
								id="price${u.sceneryId}" name="price" style="border: none;" /></td>
							<td><input type="text" value="${u.sceneryPosition }"
								id="position${u.sceneryId}" name="position"
								style="border: none;" /></td>

							<td><img src="ImgshowSceneryServlet?fileName=${u.sceneryPhoto}" id="img3"
								style="width: 110px; height: 100px;" /></td>


							<td><textarea rows="5" cols="5" name="introduce"
									id="introduce${u.sceneryId}" style="border: none;">${u.sceneryIntroduce }</textarea>
							</td>




							<td><p>
									<a
										href="DeleteSceneryServlet?sceneryId=${u.sceneryId}&page=${page}"  onclick="shanchu()">删除</a>
								</p>
								<p>
									<a onclick="xg(${u.sceneryId})">修改</a>
								</p></td>
							<script type="text/javascript">
								function xg(idxg) {
									var id = $("#id" + idxg).val();
									var name = $("#name" + idxg).val();
									var price = $("#price" + idxg).val();
									var position = $("#position" + idxg).val();
									var introduce = $("#introduce" + idxg).val();
									$.ajax({
										url : "UpdateSceneryServlet",
										type : "get",
										data : {
											id : id,
											name : name,
											price : price,
											position : position,
											introduce : introduce
										},
										success : function(data) {
											if (data = 1) {
												alert("修改成功");
											} else {
												alert("修改失败");
											}
							
										},
										error : function(data) {
											alert("修改失败");
										}
									});
								}
							</script>
						</tr>

					</c:forEach>

				</table>

			</center>


		</div>
		<center>
			<div style="width: 600px;height: 50px; margin: 0 auto ">
				<div style=" margin-left: 130px">
					<input type="button" onclick="shou()" value="首页"> <input
						type="button" onclick="shang(${page })" value="上一页"> <input
						type="button" onclick="xia(${page })" value="下一页"> <input
						type="button" onclick="wei()" value="尾页"> <span>当前页数[${page }]&nbsp;&nbsp;总页数[${pagecount}]</span>
				</div>
		</center>
	</div>
	<script type="text/javascript">
var i=${page};
//尾页直接给一个最大值首页直接给1传入
var j=99;
var k=1;
/* alert(i); */
function shou() {
		$.post("SelectSceneryServlet?op=select2",{page:k+"/sy"},function(obj){		
			$("#dyn").html(obj);
	}) 
}
function wei() {
		$.post("SelectSceneryServlet?op=select2",{page:j+"/wy"},function(obj){		
			$("#dyn").html(obj);
	}) 
}
function shang(i) {	
	//方法必须传值,也就是当前index
	$.post("SelectSceneryServlet?op=select2",{page:i+"/s"},function(obj){		
		$("#dyn").html(obj);//传本页数字加字母到weiyeServlet判断
}) 
}
function xia(i) {
	//方法必须传值,也就是当前index
	 $.post("SelectSceneryServlet?op=select2",{page:i+"/x"},function(obj){		
		$("#dyn").html(obj);
})  
}
</script>

</body>
</html>
